﻿<Window x:Class="StackHash.PluginDiagnostics"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vcs="clr-namespace:StackHash.ValueConverters"
        Title="Plugin Diagnostics - StackHash" Height="450" MinHeight="450" Width="550" MinWidth="550" Icon="/StackHash;component/StackHash.ico" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" Closed="Window_Closed">
    <Window.CommandBindings>
        <CommandBinding Command="Help" x:Name="commandBindingHelp" Executed="commandBindingHelp_Executed" />
    </Window.CommandBindings>
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MasterResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid Name="gridMain">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <TextBlock FontWeight="Bold" Margin="10,10,10,0" Grid.ColumnSpan="2">All Plugins:</TextBlock>

        <ListView Margin="10,3,10,10" Grid.Row="1" Grid.ColumnSpan="2" SelectionMode="Single" ItemsSource="{Binding AvailablePlugIns}" Name="listViewAllPlugins" GridViewColumnHeader.Click="listViewAllPlugins_Click" SelectionChanged="listViewAllPlugins_SelectionChanged">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="75">
                        <GridViewColumnHeader Tag="Loaded" Content="Loaded" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Loaded, Converter={StaticResource boolToYesNoConverter}}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="150">
                        <GridViewColumnHeader Tag="Name" Content="Name" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="150">
                        <GridViewColumnHeader Tag="FileName" Content="Location" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding FileName}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="100">
                        <GridViewColumnHeader Tag="LastException" Content="Last Exception" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding LastException, Converter={StaticResource firstLineConverter}}" ToolTip="{Binding LastException}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        
        <TextBlock FontWeight="Bold" Margin="10,0,10,0" Grid.Row="2">Global Diagnostics:</TextBlock>

        <ListView Margin="10,3,10,10" Grid.Row="3" SelectionMode="Single" ItemsSource="{Binding ElementName=listViewAllPlugins, Path=SelectedItem.Diagnostics}" Name="listViewGlobalDiagnostics" GridViewColumnHeader.Click="listViewGlobalDiagnostics_Click">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="100">
                        <GridViewColumnHeader Tag="Name" Content="Name" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="100">
                        <GridViewColumnHeader Tag="Value" Content="Value" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Value, Converter={StaticResource firstLineConverter}}" ToolTip="{Binding Value}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        
        <TextBlock FontWeight="Bold" Margin="10,0,10,0" Grid.Row="2" Grid.Column="1" Name="textBlockProfileDiagnostics">Profile Diagnostics:</TextBlock>

        <ListView Margin="10,3,10,10" Grid.Row="3" Grid.Column="1" SelectionMode="Single" ItemsSource="{Binding CurrentPluginDiagnostics}" Name="listViewProfileDiagnostics" GridViewColumnHeader.Click="listViewProfileDiagnostics_Click">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="100">
                        <GridViewColumnHeader Tag="Name" Content="Name" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Width="100">
                        <GridViewColumnHeader Tag="Value" Content="Value" />
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Value, Converter={StaticResource firstLineConverter}}" ToolTip="{Binding Value}" HorizontalAlignment="Left" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

        <Border Grid.Row="4" Grid.ColumnSpan="2" Style="{StaticResource ButtonBorder}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Button Margin="10" Command="Help">_Help</Button>

                <Button Margin="10" Grid.Column="1" HorizontalAlignment="Right" IsDefault="True" Name="buttonClose" Click="buttonClose_Click">Close</Button>
                
            </Grid>
        </Border>

    </Grid>
</Window>
